<template>
  <lb-table
    ref="lbTable"
    border
    highlight-current-row
    element-loading-text="加载中"
    :column="tableData.column"
    :data="tableData.data"
    pagination
    :total="tableData.total"
    @fetch="getData"
  />
</template>

<script>
  import { carTypeMap } from '@/utils/map'
  import { customerCustomercard } from '@/api'
  export default {
    name: 'tab-certificate',
    props: ['csmId'],
    data() {
      return {
        tableData: {
          column: [
            {
              prop: 'cardType',
              label: '证件类型',
              render: (h, { row }) => <span>{ row.cardType && carTypeMap[row.cardType] }</span>
            },
            {
              prop: 'cardNo',
              label: '证件编号'
            },
            {
              prop: 'remark',
              label: '备注'
            }
          ],
          data: []
        }
      }
    },
    methods: {
      async getData({ currentPage = 1, pageSize = 20 }) {
        const params = {
          currentPage,
          pageSize,
          csmId: String(this.csmId)
        }
        const res = await customerCustomercard(params)
        this.tableData.data = res.data.rows
        if (currentPage === 1) this.tableData.total = res.data.total
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
